﻿using System;
using SharedKeyGenerator.Model;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

namespace SharedKeyGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            // Loading domain configuration section with name "Default".
            var domainConfiguration = DomainConfiguration.Load("Default");
            var domain = Domain.Build(domainConfiguration);

            using (var session = domain.OpenSession()) {
                using (var t = session.OpenTransaction()) {

                    // By default, DataObjects.Net uses the same key generator for all hierarchies with identical key structure
                    // This is done for optimization purposes

                    Console.WriteLine(Key.Generate<Customer>(session));
                    Console.WriteLine(Key.Generate<Product>(session));
                    Console.WriteLine(Key.Generate<Customer>(session));
                    Console.WriteLine(Key.Generate<Product>(session));
                    Console.WriteLine(Key.Generate<Customer>(session));
                    Console.WriteLine(Key.Generate<Product>(session));

                    t.Complete();
                }
            }
        }
    }
}
